<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAssetsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('assets', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->bigInteger('user_id')->index()->comment('用户ID');
            $table->string('source_type')->default(\App\Enums\AssetSourceType::ORDER)->comment('资产来源');
            $table->bigInteger('source_id')->comment('资产来源ID');
            $table->string('contract_address')->index()->comment('作品标识');
            $table->string('token_id')->comment('资产凭证ID');
            $table->string('trans_hash', 128)->comment('资产交易凭证');
            $table->string('asset_status', 16)->default(\App\Enums\AssetStatus::HOLD)->comment('资产状态');
            $table->index(['source_type', 'source_id']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('assets');
    }
}
